/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.kramerius.imagelinkfixer;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * 
 * @author Martin Řehánek <rehan at mzk.cz>
 */
public class UuidPdfMapping {

    private final Map<String, String> mapping;

    public UuidPdfMapping(File mappingFile) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(mappingFile));
        mapping = new HashMap<String, String>();
        while (reader.ready()) {
            String line = reader.readLine();
            String[] parts = line.split(":");
            if (parts.length != 2) {
                throw new IllegalArgumentException("incorrect line '" + line + "'");
            }
            mapping.put(parts[0], parts[1]);
        }
    }

    public String getPdfFile(String uuid) {
        return mapping.get(uuid);
    }

    public Set<String> getUuidSet() {
        return mapping.keySet();
    }
}
